
//删帖的确认
function showMsg(tid) {

	if (confirm("确定要删除吗")) {
		var deltoken=Math.random();
		var uri = "scan!deleteTopic.action?tid=" + tid+"&deltoken="+deltoken;
	
		window.location.href = uri;
		// alert("您删除了该帖子");
	}
	;
}
//发帖
function checkInfo() {
	// action="scan!posting.action"


	var content = CKEDITOR.instances.content.getData();
	var title = document.getElementById("title").value;

	var section = document.getElementById("sectionId");

	var sid = section.options[section.selectedIndex].value;
	var permission = document.getElementById("publishLimit").value;
	
	if(permission=="")
	{
		alert("请先登录!");
		var uri="forum/jsp/login.jsp";
		window.location.href=uri;
		return;
	}
	if (permission == "false") {
		alert("您没有发帖权限");
		return;
	}

	if (title == "") {
		alert("给您的帖子起个题目吧！");
		return;

	} else if (content == "") {
		alert("请写一些东西再发表吧！");
		return;
	}

	//防止重复提交
	var token=Math.random();

	
	var uri = "scan!posting.action?sid=" + sid + "&title=" + title
			+ "&content=" + content+"&pubtoken="+token;


	uri = encodeURI(uri);
	uri = encodeURI(uri);
	window.location.href = uri;

}


function gotoPage() {
	var pageCode = document.getElementById("txtPageCode").value;

	var tid = document.getElementById("tid").value;

	var uri = "scan!showTopicReplys.action?tid=" + tid + "&pageCode="
			+ pageCode;

	window.location.href = uri;
}

function toResult(num) {

	var pageCode = num;
	var tid = document.getElementById("tid").value;
	var uri = "scan!showTopicReplys.action?tid=" + tid + "&pageCode="
			+ pageCode;
	location = uri;
}
function initPage() {
	var div_a = document.getElementById("div_a");
	//获得总页数
	var totalPage = document.getElementById("totalPage").value;

	var nodes = div_a.childNodes;
	var arr = []; //存放所有分页标签a标记
	for ( var i = 0; i < nodes.length; i++) {
		if (nodes[i].nodeType == 1) {
			arr.push(nodes[i]);
		}
	}

	//获得当前页

	var currPage = document.getElementById("txtPageCode").value;
	if (currPage >5) {
		for ( var i = 0; i < currPage - 5; i++) {
			div_a.removeChild(arr[i]);
		}
	}

	if (totalPage - currPage >5) {

		for ( var i = parseInt(currPage) + 5; i <= parseInt(totalPage); i++) {
			div_a.removeChild(arr[i]);
		}
	}
}
//回复的校验
function checkRpyInfo() {
	// action="scan!posting.action"

	var content = CKEDITOR.instances.content.getData();//document.getElementById("content").value;
	//alert(content);

	var tid = document.getElementById("tid").value;
	var reply = document.getElementById("replyLimit").value;

	if (reply== "") {
	//	alert("跳转到登录页面");
		var uri = "forum/jsp/login.jsp";
		window.location.href = uri;
		return;
	}
	if (reply == "false") {
		alert("您没有发帖权限");
		return;
	}

	if (content == "") {
		alert("请写一些东西再发表吧！");
		return;
	}
	var token=Math.random();
	var uri = "scan!reply.action?tid=" + tid + "&content=" + content+"&rpytoken="+token;

	//alert(uri);
	uri = encodeURI(uri);
	uri = encodeURI(uri);
	window.location.href = uri;
}

//引用
function quoting(rid) {
	
	var name=document.getElementById(rid+"_name").innerHTML;
	var time=document.getElementById(rid+"_time").innerHTML;
	var content=document.getElementById(rid+"_content").innerHTML;
	
	text="<span class=quoting>引用:"+name+time+"    "+content+"</span></br></p>";
	CKEDITOR.instances.content.setData(text);
}
//回复
function reply(rid)
{
	var name=document.getElementById(rid+"_name").innerHTML;
	text="<span class=reply>回复:"+name+"</span></br></p>";
	CKEDITOR.instances.content.setData(text);
}
//删除回复
function delRpy(rid,tid)
{
	//alert("删除");
	//alert("rid:"+rid);
	//alert("tid:"+tid);
	var token=Math.random();
	
	
	var uri = "scan!delRpyById.action?rid=" + rid +"&tid="+tid+"&rpyDelToken="+token;
	window.location.href = uri;
}
//版块删除确认
function makeConfirm(sid) {
	confirm("确定要删除该板块吗");
	var uri = "admin!deleteSection?sid=" + sid;
	window.location.href = uri;
}

//div切换
function setTab(name, cursel) {
	var contt = document.getElementById("contt");
	var n = contt.childNodes.length;
	for (i = 1; i <= n; i++) {
		var menu = document.getElementById(name + i);
		var con = document.getElementById(name + "_" + i);
		menu.className = i == cursel ? "hover" : "";
		con.style.display = i == cursel ? "block" : "none";
	}
}
//用户审核
function registerPermit() {
	var checkboxs = document.getElementsByName("ckeckbox");
	var uids = new Array;
	for ( var i = 0; i < checkboxs.length; i++) {

		if (checkboxs[i].checked == true) {
			//alert(checkboxs[i].id);
			uids.push(checkboxs[i].id);
		}
	}
	//alert(uids);
	if (uids.length == 0) {
		alert("您没选中任何用户");
		return;
	}
	var uri = "admin!registerPermits.action?uids=" + uids;
	window.location.href = uri;
};
function ignore() {
	var checkboxs = document.getElementsByName("ckeckbox");
	var uids = new Array;
	for ( var i = 0; i < checkboxs.length; i++) {

		if (checkboxs[i].checked == true) {
			//alert(checkboxs[i].id);
			uids.push(checkboxs[i].id);
		}
	}
	//alert(uids);
	if (uids.length == 0) {
		alert("您没选中任何用户");
		return;
	}
	var uri = "admin!ignore.action?uid=" + uids;
	window.location.href = uri;

};
function checkAll() {
	var selectAll = document.getElementById("selectAll");
	var checkboxs = document.getElementsByName("ckeckbox");
	if (selectAll.checked == false) {
		//取消全选
		//alert("取消全选");
		for ( var i = 0; i < checkboxs.length; i++) {
			checkboxs[i].checked = false;
		}

	} else {
		//全选
		//alert("全选");
		for ( var i = 0; i < checkboxs.length; i++) {
			checkboxs[i].checked = true;
		}
	}
}
